/*
 * Copyright 2011 Katsunori Koyanagi
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package sweezy.swf.abc
{
	import flash.utils.ByteArray;
	import sweezy.swf.ISerializable;
	import sweezy.swf.abc.structure.ConstantPoolInfo;
	import sweezy.swf.decoder.ABCDecoder;
	import sweezy.swf.encoder.ABCEncoder;

	public class ABC extends ABCStructure implements ISerializable
	{

		public var classInfos:Array;

		public var constantPool:ConstantPoolInfo;

		public var instanceInfos:Array;

		public var majorVersion:uint;

		public var metadataInfos:Array;

		public var methodBodyInfos:Array;

		public var methodInfos:Array;

		public var minorVersion:uint;

		public var scriptInfos:Array;

		public function ABC()
		{
			super("ABC");
		}

		public function decode(bytes:ByteArray):void
		{
			var abc:ABC = new ABCDecoder().decode(bytes);
			if (abc !== null)
			{
				classInfos = abc.classInfos;
				constantPool = abc.constantPool;
				instanceInfos = abc.instanceInfos;
				majorVersion = abc.majorVersion;
				metadataInfos = abc.metadataInfos;
				methodBodyInfos = abc.methodBodyInfos;
				methodInfos = abc.methodInfos;
				minorVersion = abc.minorVersion;
				scriptInfos = abc.scriptInfos;
			}
		}

		public function encode():ByteArray
		{
			return new ABCEncoder().encode(this);
		}
	}
}
